<template>
    <div class="info">
        <!-- 卡片视图 -->
        <el-card shadow="never">
            <el-form ref="addInfo" :model="addInfo" label-width="0">
                <el-form-item prop="content">
                    <mavon-editor v-model="addInfo.content" ref="md" />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">保存</el-button>
                </el-form-item>
            </el-form>
        </el-card>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                addInfo: {},
            }
        },
        created() {
            this.getInfoContent()
        },
        methods: {
            async getInfoContent() {
                const { data: res } = await this.$http.get('infoContent')
                if (res.status !== 200) {
                    return this.$message.error(res.message)
                }
                this.addInfo = res.results[0]
            },
            async onSubmit() {
                const { data: res } = await this.$http.put(
                    '/infoContent/' + this.addInfo.id,
                    this.addInfo
                )
                console.log(this.editArticleform)
                if (res.status !== 200) {
                    return this.$message.error(res.message)
                }
                console.log(res)
                this.$message.success(res.message)
            },
        },
    }
</script>
